/*
 Copyright (c) 2008 TPSi
 Alex Iskander
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:
 
 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 
 */
#include <sstream>

TEST(ConverterTest, IsWorking)
{
	/* 
	 Test:
	 Creates a bound integer, a string, a bool, a double, and a pointer.
	 - Sets initial values for these properties
	 
	 Creates another bound string.
	 - Sets its converter to a new GenericConverter
	 - For each of the previously created bound variables, binds and checks value.
	 - - Also, changes the value one and tests again.
	 
	 */
	
	/* Create Integer */
	Bind::Bound<int> integerValue;
	integerValue= 5;
	
	//sanity check
	ASSERT_EQ(integerValue.get(), 5);

	
	/* Create Double */
	Bind::Bound<double> doubleValue;
	doubleValue = 2.54;
	
	//sanity check
	ASSERT_EQ(doubleValue.get(), 2.54);

	
	
	/* Create Bool */
	Bind::Bound<bool> boolValue;
	boolValue = true;
	
	//sanity check
	ASSERT_EQ(boolValue.get(), true);
	

	
	/* Run test */
	//create test variable
	Bind::Bound<std::string> test;
	
	//initialize converter
	test.convert(new GenericConverter());
	
	
	/* Test integer conversion */
	//set to integer
	test = integerValue;
	
	//test
	ASSERT_EQ(test.get(), "5");
	
	//set integer to something else
	integerValue = 6;
	ASSERT_EQ(test.get(), "6");

	
	/* Test double conversion */
	//set to double
	test = doubleValue;
	
	//test
	ASSERT_EQ(test.get(), "2.540");
	
	//set double to something else
	doubleValue = 6.95;
	ASSERT_EQ(test.get(), "6.950");
	
	/* Test bool conversion */
	//set to bool
	test = boolValue;
	
	//test
	ASSERT_EQ(test.get(), "true");
	
	//set integer to something else
	boolValue = false;
	ASSERT_EQ(test.get(), "false");
	
}
